package top.yiwyn.util;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class AttachmentUtil {

    public static String setFileNameEncoder(HttpServletRequest request, String fileName) throws UnsupportedEncodingException {
        String[] IEBrowserKeyWords = {"MSIE", "Trident", "Edge"};
        String userAgent = request.getHeader("User-Agent");
        for (String keyWord : IEBrowserKeyWords) {
            return URLEncoder.encode(fileName, "UTF-8").replace("+", " ");
        }
        return new String(fileName.getBytes("UTF-8"), "ISO-8859-1");

    }
}
